<%@ page contentType="text/html; charset=utf-8" language="java" errorPage="" %>
<%@ page import="javax.naming.Context"%> 
<%@ page import="javax.sql.DataSource"%> 
<%@ page import="javax.naming.InitialContext"%> 
<%@ page import="java.sql.*"%> 
<%@page import="dataconn.dataconn;"%> 
<%
  Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance(); 
  String url="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=BugFree"; 
  String user="sa"; 
  String password="sa";   
  Connection conn= DriverManager.getConnection(url,user,password);
     request.setCharacterEncoding("utf-8");
     String GroupName=request.getParameter("groupname");
     int GroupID=Integer.parseInt(request.getParameter("GroupID"));
     String Users[]=request.getParameterValues("User2");
     String Projects[]=request.getParameterValues("Project2");
     CallableStatement cstmt = conn.prepareCall("{ call EditGroup(?, ?) }"); 
     cstmt.setString(1, GroupName);
     cstmt.setInt(2,GroupID);
     for(int i=0;i<Users.length;i++)
     {
          cstmt=conn.prepareCall("{call Insert_User(?,?)}");
          cstmt.setString(1, Users[i]);
          cstmt.setInt(2,GroupID);
         
     }
          for(int j=0;j<Projects.length;j++)
     {
          cstmt=conn.prepareCall("{call Insert_Project(?,?)}");
          cstmt.setString(1, Projects[j]);
          cstmt.setInt(2,GroupID);         
     }
     response.sendRedirect("AddGroup.jsp");
 %>
 
